home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / FRMFILTE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-26  |  17.5 KB  |  434 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  3. Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
  4. Begin VB.Form frmFilters 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Filters..."
  7.    ClientHeight    =   3255
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   8340
  11.    Icon            =   "frmFilters.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3255
  16.    ScaleWidth      =   8340
  17.    StartUpPosition =   1  'CenterOwner
  18.    Begin VB.Frame fraAttributes 
  19.       Caption         =   "Limit processing based on file attributes:"
  20.       BeginProperty Font 
  21.          Name            =   "MS Sans Serif"
  22.          Size            =   8.25
  23.          Charset         =   0
  24.          Weight          =   700
  25.          Underline       =   0   'False
  26.          Italic          =   0   'False
  27.          Strikethrough   =   0   'False
  28.       EndProperty
  29.       Height          =   2535
  30.       Left            =   3850
  31.       TabIndex        =   13
  32.       Top             =   120
  33.       Width           =   4350
  34.       Begin ComctlLib.ListView lstExcludedAttributes 
  35.          Height          =   1935
  36.          Left            =   2250
  37.          TabIndex        =   2
  38.          Top             =   480
  39.          Width           =   1935
  40.          _ExtentX        =   3413
  41.          _ExtentY        =   3413
  42.          View            =   3
  43.          Arrange         =   1
  44.          LabelEdit       =   1
  45.          MultiSelect     =   -1  'True
  46.          LabelWrap       =   -1  'True
  47.          HideSelection   =   -1  'True
  48.          HideColumnHeaders=   -1  'True
  49.          _Version        =   327680
  50.          ForeColor       =   -2147483640
  51.          BackColor       =   -2147483643
  52.          BorderStyle     =   1
  53.          Appearance      =   1
  54.          MouseIcon       =   "frmFilters.frx":030A
  55.          NumItems        =   1
  56.          BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  57.             Key             =   ""
  58.             Object.Tag             =   ""
  59.             Text            =   "Attribute"
  60.             Object.Width           =   2540
  61.          EndProperty
  62.       End
  63.       Begin ComctlLib.ListView lstRequiredAttributes 
  64.          Height          =   1935
  65.          Left            =   120
  66.          TabIndex        =   1
  67.          Top             =   480
  68.          Width           =   1935
  69.          _ExtentX        =   3413
  70.          _ExtentY        =   3413
  71.          View            =   3
  72.          Arrange         =   1
  73.          LabelEdit       =   1
  74.          MultiSelect     =   -1  'True
  75.          LabelWrap       =   -1  'True
  76.          HideSelection   =   -1  'True
  77.          HideColumnHeaders=   -1  'True
  78.          _Version        =   327680
  79.          ForeColor       =   -2147483640
  80.          BackColor       =   -2147483643
  81.          BorderStyle     =   1
  82.          Appearance      =   1
  83.          MouseIcon       =   "frmFilters.frx":0326
  84.          NumItems        =   1
  85.          BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  86.             Key             =   ""
  87.             Object.Tag             =   ""
  88.             Text            =   "Attribute"
  89.             Object.Width           =   2769
  90.          EndProperty
  91.       End
  92.       Begin VB.Label lblExcludedAtrributes 
  93.          Caption         =   "These attributes must be off:"
  94.          Height          =   255
  95.          Left            =   2250
  96.          TabIndex        =   15
  97.          Top             =   240
  98.          Width           =   2055
  99.       End
  100.       Begin VB.Label lblRequiredAttributes 
  101.          Caption         =   "These attributes must be on:"
  102.          Height          =   255
  103.          Left            =   120
  104.          TabIndex        =   14
  105.          Top             =   240
  106.          Width           =   2055
  107.       End
  108.    End
  109.    Begin VB.Frame fraSize 
  110.       Caption         =   "Limit processing by a file's size:"
  111.       BeginProperty Font 
  112.          Name            =   "MS Sans Serif"
  113.          Size            =   8.25
  114.          Charset         =   0
  115.          Weight          =   700
  116.          Underline       =   0   'False
  117.          Italic          =   0   'False
  118.          Strikethrough   =   0   'False
  119.       EndProperty
  120.       Height          =   1170
  121.       Left            =   120
  122.       TabIndex        =   8
  123.       Top             =   1485
  124.       Width           =   3615
  125.       Begin VB.TextBox txtMinSizeToProcess 
  126.          Height          =   285
  127.          Left            =   1560
  128.          TabIndex        =   16
  129.          Top             =   360
  130.          Width           =   1095
  131.       End
  132.       Begin VB.TextBox txtMaxSizeToProcess 
  133.          Height          =   278
  134.          Left            =   1560
  135.          TabIndex        =   0
  136.          Top             =   765
  137.          Width           =   1095
  138.       End
  139.       Begin VB.Label lblk2 
  140.          Caption         =   "K"
  141.          Height          =   240
  142.          Left            =   2760
  143.          TabIndex        =   12
  144.          Top             =   795
  145.          Width           =   135
  146.       End
  147.       Begin VB.Label lblk1 
  148.          Caption         =   "K"
  149.          Height          =   240
  150.          Left            =   2760
  151.          TabIndex        =   11
  152.          Top             =   390
  153.          Width           =   255
  154.       End
  155.       Begin VB.Label lblMaxSizeToProcess 
  156.          Caption         =   "Maximum size:"
  157.          Height          =   255
  158.          Left            =   360
  159.          TabIndex        =   10
  160.          Top             =   765
  161.          Width           =   1215
  162.       End
  163.       Begin VB.Label lblMinSizeToProcess 
  164.          Caption         =   "Minimum size:"
  165.          Height          =   255
  166.          Left            =   360
  167.          TabIndex        =   9
  168.          Top             =   360
  169.          Width           =   1095
  170.       End
  171.    End
  172.    Begin VB.Frame fraDates 
  173.       Caption         =   "Limit processing based on a file's date:"
  174.       BeginProperty Font 
  175.          Name            =   "MS Sans Serif"
  176.          Size            =   8.25
  177.          Charset         =   0
  178.          Weight          =   700
  179.          Underline       =   0   'False
  180.          Italic          =   0   'False
  181.          Strikethrough   =   0   'False
  182.       EndProperty
  183.       Height          =   1170
  184.       Left            =   120
  185.       TabIndex        =   4
  186.       Top             =   120
  187.       Width           =   3615
  188.       Begin MSMask.MaskEdBox mebMaxDateToProcess 
  189.          Height          =   285
  190.          Left            =   1560
  191.          TabIndex        =   17
  192.          Top             =   765
  193.          Width           =   1095
  194.          _ExtentX        =   1931
  195.          _ExtentY        =   503
  196.          _Version        =   327680
  197.          PromptChar      =   "#"
  198.       End
  199.       Begin MSMask.MaskEdBox mebMinDateToProcess 
  200.          Height          =   285
  201.          Left            =   1560
  202.          TabIndex        =   18
  203.          Top             =   360
  204.          Width           =   1095
  205.          _ExtentX        =   1931
  206.          _ExtentY        =   503
  207.          _Version        =   327680
  208.          ClipMode        =   1
  209.          HideSelection   =   0   'False
  210.          Format          =   "c"
  211.          PromptChar      =   "_"
  212.       End
  213.       Begin VB.Label lblMaxDateToProcess 
  214.          Caption         =   "Maximum date:"
  215.          Height          =   255
  216.          Left            =   360
  217.          TabIndex        =   7
  218.          Top             =   765
  219.          Width           =   1215
  220.       End
  221.       Begin VB.Label lblMinDateToProcess 
  222.          Caption         =   "Minimum date:"
  223.          Height          =   255
  224.          Left            =   360
  225.          TabIndex        =   6
  226.          Top             =   360
  227.          Width           =   1095
  228.       End
  229.    End
  230.    Begin VB.CommandButton cmdOk 
  231.       Caption         =   "&OK"
  232.       Height          =   375
  233.       Left            =   5900
  234.       TabIndex        =   3
  235.       Top             =   2790
  236.       Width           =   1095
  237.    End
  238.    Begin VB.CommandButton cmdCancel 
  239.       Cancel          =   -1  'True
  240.       Caption         =   "&Cancel"
  241.       Height          =   375
  242.       Left            =   7115
  243.       TabIndex        =   5
  244.       Top             =   2790
  245.       Width           =   1095
  246.    End
  247. Attribute VB_Name = "frmFilters"
  248. Attribute VB_GlobalNameSpace = False
  249. Attribute VB_Creatable = False
  250. Attribute VB_PredeclaredId = True
  251. Attribute VB_Exposed = False
  252. Option Explicit
  253. '=============================================================================
  254. ' Description: The frmFilters form lets the user limit the processing of files
  255. '              to files matching certain criteria such as file date, file size,
  256. '              and file attributes.
  257. '=============================================================================
  258. '------------------------------------------------------------------------------------
  259. ' Validates the dates entered into the form's controls
  260. '------------------------------------------------------------------------------------
  261. Private Function CheckDates() As Boolean
  262.     Dim ValidDate As Date
  263.     On Error Resume Next
  264.     ValidDate = CDate(mebMinDateToProcess.Text)
  265.     ValidDate = CDate(mebMaxDateToProcess.Text)
  266.     If Err > 0 Then
  267.         CheckDates = False
  268.     Else
  269.         CheckDates = True
  270.     End If
  271. End Function
  272. '------------------------------------------------------------------------------------
  273. ' Initializes the form's listboxes with xZip's property values
  274. '--------------------------------------------------------------------------------
  275. Private Sub InitializeForm(xZip As XceedZip)
  276.     Dim counter As Integer
  277.     ' Load the minimum and maximum size to process onto the form's controls
  278.     txtMinSizeToProcess.Text = Val(xZip.MinSizeToProcess) / 1024
  279.     txtMaxSizeToProcess.Text = Val(xZip.MaxSizeToProcess) / 1024
  280.     ' Set the RequiredFileAttributes and ExcludedFileAttributes in the lists
  281.     For counter = 1 To lstRequiredAttributes.ListItems.Count
  282.         lstRequiredAttributes.ListItems(counter).Selected = _
  283.             ((xZip.RequiredFileAttributes And Val(lstRequiredAttributes.ListItems(counter).Tag)) > 0)
  284.     Next counter
  285.     For counter = 1 To lstExcludedAttributes.ListItems.Count
  286.         lstExcludedAttributes.ListItems(counter).Selected = _
  287.             ((xZip.ExcludedFileAttributes And Val(lstExcludedAttributes.ListItems(counter).Tag)) > 0)
  288.     Next counter
  289.     ' Reads and formats the dates as defined by the current
  290.     ' operating system settings
  291.     mebMinDateToProcess.Text = Format(xZip.MinDateToProcess, "General Date")
  292.     mebMaxDateToProcess.Text = Format(xZip.MaxDateToProcess, "General Date")
  293.     ' Loads the "mouseover tips" so the user can easily see the
  294.     ' system's date format.
  295.     Call LoadDateTips
  296. End Sub
  297. '------------------------------------------------------------------------------------
  298. ' Places the tooltiptext which shows the user the system's date format
  299. '------------------------------------------------------------------------------------
  300. Private Sub LoadDateTips()
  301.     Dim dateFormat As String
  302.     dateFormat = Format("2039-12-27", "General Date")
  303.     mebMaxDateToProcess.ToolTipText = "Format is " + dateFormat
  304.     mebMinDateToProcess.ToolTipText = "Format is " + dateFormat
  305. End Sub
  306. '------------------------------------------------------------------------------------
  307. 'Initializes the required and excluded file attributes listboxes
  308. '------------------------------------------------------------------------------------
  309. Private Sub Loadlistboxes(xZip As XceedZip)
  310.     lstRequiredAttributes.ListItems.Clear
  311.     lstExcludedAttributes.ListItems.Clear
  312.     Dim archive As ListItem
  313.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Archive")
  314.     archive.Tag = xfaArchive
  315.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Folder")
  316.     archive.Tag = xfaFolder
  317.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Hidden")
  318.     archive.Tag = xfaHidden
  319.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Read-Only")
  320.     archive.Tag = xfaReadOnly
  321.     Set archive = lstRequiredAttributes.ListItems.Add(, , "System")
  322.     archive.Tag = xfaSystem
  323.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Volume")
  324.     archive.Tag = xfaVolume
  325.     Set archive = lstRequiredAttributes.ListItems.Add(, , "Compressed")
  326.     archive.Tag = xfaCompressed
  327.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Archive")
  328.     archive.Tag = xfaArchive
  329.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Folder")
  330.     archive.Tag = xfaFolder
  331.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Hidden")
  332.     archive.Tag = xfaHidden
  333.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Read-Only")
  334.     archive.Tag = xfaReadOnly
  335.     Set archive = lstExcludedAttributes.ListItems.Add(, , "System")
  336.     archive.Tag = xfaSystem
  337.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Volume")
  338.     archive.Tag = xfaVolume
  339.     Set archive = lstExcludedAttributes.ListItems.Add(, , "Compressed")
  340.     archive.Tag = xfaCompressed
  341. End Sub
  342. '------------------------------------------------------------------------------------
  343. ' Opens up the frmFilters form
  344. '------------------------------------------------------------------------------------
  345. Public Function ShowForm(xZip As XceedZip) As Boolean
  346.       
  347.     ' Initialise the form's tag, which is used later to determine
  348.     ' if the OK button was pressed to accept the changes
  349.     frmFilters.Tag = "0"
  350.     'Loads the required and excluded attributes listboxes
  351.     Call Loadlistboxes(xZip)
  352.      
  353.     ' Loads the xZip object's property values into the frmFilters
  354.     ' form's controls
  355.     Call InitializeForm(xZip)
  356.      
  357.     ' Shows the form
  358.     frmFilters.Show vbModal
  359.      
  360.     ' If tag = "1" then the user clicked on Ok and the form's controls
  361.     ' values are copied in the xZip properties
  362.     If frmFilters.Tag = "1" Then
  363.         Call UpdateDataToxZip(xZip)
  364.     End If
  365.      
  366.     ' If tag = "1" then the user clicked on OK and the procedure returns TRUE
  367.     ShowForm = (frmFilters.Tag = "1")
  368. End Function
  369. '------------------------------------------------------------------------------------
  370. 'Forces the user to enter numerical caracters in the MaxSizeToProgress
  371. 'textbox.
  372. '------------------------------------------------------------------------------------
  373. Private Sub txtMaxSizeToProcess_KeyPress(KeyAscii As Integer)
  374.     KeyAscii = ValidateNumbers(KeyAscii)
  375. End Sub
  376. '------------------------------------------------------------------------------------
  377. 'Forces the user to enter numerical caracters in the MinSizeToProgress
  378. 'textbox.
  379. '------------------------------------------------------------------------------------
  380. Private Sub txtMinSizeToProcess_KeyPress(KeyAscii As Integer)
  381.     KeyAscii = ValidateNumbers(KeyAscii)
  382. End Sub
  383. '------------------------------------------------------------------------------------
  384. 'Sets the xZip object's properties according to the settings
  385. 'of the form's controls
  386. '------------------------------------------------------------------------------------
  387. Private Function UpdateDataToxZip(xZip As XceedZip)
  388.     Dim counter As Integer
  389.     'Set the MinSizeToProcess and MaxSizeToProcess properties...
  390.     xZip.MinSizeToProcess = Val(txtMinSizeToProcess.Text) * 1024
  391.     xZip.MaxSizeToProcess = Val(txtMaxSizeToProcess.Text) * 1024
  392.     'Set the RequiredFileAttributes property...
  393.     xZip.RequiredFileAttributes = xfaNone
  394.     xZip.ExcludedFileAttributes = xfaNone
  395.     For counter = 1 To lstRequiredAttributes.ListItems.Count
  396.         If lstRequiredAttributes.ListItems(counter).Selected Then
  397.             xZip.RequiredFileAttributes = xZip.RequiredFileAttributes + Val(lstRequiredAttributes.ListItems(counter).Tag)
  398.         End If
  399.     Next counter
  400.     'Set the ExcludedFileAttributes property...
  401.     For counter = 1 To lstExcludedAttributes.ListItems.Count
  402.         If lstExcludedAttributes.ListItems(counter).Selected Then
  403.              xZip.ExcludedFileAttributes = xZip.ExcludedFileAttributes + Val(lstExcludedAttributes.ListItems(counter).Tag)
  404.         End If
  405.     Next counter
  406.     'Set the MinDateToProcess and MaxDateToProcess properties
  407.     xZip.MinDateToProcess = CDate(mebMinDateToProcess.Text)
  408.     xZip.MaxDateToProcess = CDate(mebMaxDateToProcess)
  409. End Function
  410. '------------------------------------------------------------------------------------
  411. ' The user clicked on Cancel and tag stays at "0"
  412. '------------------------------------------------------------------------------------
  413. Private Sub cmdCancel_Click()
  414.     Me.Hide
  415. End Sub
  416. '------------------------------------------------------------------------------------
  417. ' The user clicked on OK and the dates are validated. If they do not fit the
  418. ' system's default date format, a message box alerts the user to change the
  419. ' dates and the tag stays at "0". If the dates are correct, the tag receives
  420. ' the "1" value, indicating that the changes should be accepted.
  421. '------------------------------------------------------------------------------------
  422. Private Sub cmdOk_Click()
  423.     Dim bDateValid      As Boolean
  424.     Dim sDateFormat     As String
  425.     bDateValid = CheckDates()
  426.     If bDateValid = False Then
  427.         sDateFormat = Format("2039-12-27", "General Date")
  428.         MsgBox "Date values are invalid. The format is " + sDateFormat, vbExclamation
  429.     Else
  430.         Me.Tag = "1"
  431.         Me.Hide
  432.     End If
  433. End Sub
  434.